#pragma once

#include "ModelessDialog.h"

// OrderDlg dialog

class OrderDlg : public CModelessDialog, public L_Observer
{
	DECLARE_DYNAMIC(OrderDlg)

public:

	enum ORDER_SEARCH_TYPE{
		REFERENCE_ID,
		ORDER_ID
	};

	enum ORDER_DISP_TYPE{
		ALL_ORDERS,
		BUY_ORDERS,
		SELL_ORDERS,
		ACTIVE_ORDERS,
		ACTIVE_BUY_ORDERS,
		ACTIVE_SELL_ORDERS
	};

	OrderDlg(L_Position *p = NULL, CWnd* pParent = NULL); // standard constructor
	virtual ~OrderDlg();

	virtual BOOL Create(CWnd *pParentWnd = CWnd::FromHandle(L_GetMainWnd()));

// Dialog Data
	enum { IDD = IDD_ORDERDLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()

protected:
// L_Observer
	virtual void HandleMessage(L_Message const *pMsg);

private:
	//Controls
	CListCtrl m_OrderDataListCtrl;
	CComboBox m_OrderCombo;

	//Control helpers
	void UpdateOrderCombo();
	void ResizeControls();
	void InitializeDataCtrlRows();
	CString GetTextForFunction(int function);
	void UpdateStaticValues();
	void UpdateDynamicValues();

	//options
	int m_OrderSearchType;
	int m_OrderDispType;

	//Data
	L_Account *account;
	L_Position *position;
	L_Order *order;

	char APIFunctions[64][32];
	void SetAPIFunctions();

public:
	virtual BOOL OnInitDialog();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnBnClickedRefIDRadio();
	afx_msg void OnBnClickedOrderIDRadio();
	afx_msg void OnCbnSelchangeOrderCombo();
	afx_msg void OnBnClickedAllRadio();
	afx_msg void OnBnClickedBuyRadio();
	afx_msg void OnBnClickedSellRadio();
	afx_msg void OnBnClickedActiveRadio();
	afx_msg void OnBnClickedActiveBuyRadio();
	afx_msg void OnBnClickedActiveSellRadio();
	afx_msg void OnViewExecutions();
	afx_msg void OnFileCancelOrder();
};
